package javamobile.utils;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Map;


public class MySocket {
	private static String host = Constants.getHostname();
	private static int port = Constants.getPort();
	@SuppressWarnings("unchecked")
	public static Map<String, Object> runSocket (Map<String, Object> input) throws UnknownHostException, IOException, ClassNotFoundException {
		Socket socket = new Socket(host,port);
		System.out.println("Android: Connected to server");
		ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
		ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
		
		
		out.writeObject(input);
		Map<String, Object> output = (Map<String, Object>) in.readObject();
		out.close();
		in.close();
		socket.close();
		return output;
	}
}